package com.ck.hxc.controller;

import com.ck.hxc.config.JwtUtils;
import com.ck.hxc.config.Result;
import com.ck.hxc.config.ThreadLocalUtils;
import com.ck.hxc.entity.SysUser;
import com.ck.hxc.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.crypto.password.PasswordEncoder;
 
@Tag(name = "用户接口")
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    /*private final SysUserService userService;

    private final JwtUtils jwtUtils;


    private final PasswordEncoder passwordEncoder;

    public UserController(PasswordEncoder passwordEncoder,SysUserService userService, JwtUtils jwtUtils) {
        this.passwordEncoder = passwordEncoder;
        this.userService = userService;
        this.jwtUtils = jwtUtils;

    }

    @Operation(summary = "登录")
    @GetMapping("/login")
    public Result login(String username, String password){
        SysUser user=userService.lambdaQuery().eq(SysUser::getUserNumber,username).one();
 
        if(user!=null && user.getPassword().equals(passwordEncoder.encode(password))){
            String token =jwtUtils.createToken(username);
            return Result.success(token);
        }
        return Result.failed("用户名或密码输入错误！");
    }
 
    @Operation(summary = "获取登录用户信息")
    @GetMapping("/userInfo")
    public Result userInfo(){
        String user = ThreadLocalUtils.get();
        return Result.success(user);
    }*/

    @GetMapping("/test1")
    public String test1(){
        System.out.println("test1");
        return "test1";
    }

}